package com.zqxq.lottery.api.controller;

import com.zqxq.common.constant.Result;
import com.zqxq.common.enums.CodeEnum;
import com.zqxq.common.utils.StrUtils;
import com.zqxq.lottery.api.feign.LotteryServerFeignClient;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.*;

/**
 * @author 苦智
 * @date 2018/10/22 17:00
 * @description 电竞赛事
 * @ClassName ESportsController
 */
@Slf4j
@Api(value = "电竞赛事",tags = "电竞赛事")
@RequestMapping(value = "/eSports",produces = "application/json")
@RestController
public class ESportsController {
    @Autowired
    private LotteryServerFeignClient lotteryServerFeignClient;

    @PostMapping("/titleList")
    @ApiOperation("电竞玩法标题列表")
    public Result eSportsTitleList(@ApiParam(value = "类型 23:欢乐猜球 10:电竞 " ,required = true)@RequestParam("type") Integer type){
        if (type == null)
            return new Result(CodeEnum.FAIL_100002.getCode(),CodeEnum.FAIL_100002.getMsg());
        return lotteryServerFeignClient.getESportsTitleList(type);
    }

    @PostMapping("/homeList")
    @ApiOperation("电竞赛事列表")
    public Result eSportsHomeList(@ApiParam(value = "页码",required = true) @RequestParam(defaultValue = "1") Integer pageNO,
                                  @ApiParam(value = "页数",required = true) @RequestParam(defaultValue = "10") Integer pageSize,
                                  @ApiParam(value = "游戏类型 0:欢乐猜球全部 99:电竞全部 1:LOL 2:DOTA2 3:CSGO 4:守望先锋 5:篮球 6:足球" ,required = false)@RequestParam(defaultValue = "0") Integer type){
        return lotteryServerFeignClient.getESportsHomeList(pageNO,pageSize,type);
    }

    @PostMapping("/playwayList")
    @ApiOperation("赛事展开玩法列表/玩法详情")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "matchId", value = "赛事id", paramType = "query", dataType = "String", required = true),
            @ApiImplicitParam(name = "round", value = "回合", paramType = "query", dataType = "String", required = false)
    })
    public Result eSportsPlaywayList(String matchId,String round){
        if (StrUtils.isEmpty(matchId))
            return new Result(CodeEnum.FAIL_100002.getCode(),CodeEnum.FAIL_100002.getMsg());
        return lotteryServerFeignClient.getESportsPlaywayList(matchId,round);
    }

    @PostMapping("/eSportsHead")
    @ApiOperation("玩法详情头部")
    public Result getESportsHead(@ApiParam(value = "赛事id",required = true) @RequestParam("matchId") String matchId){
        if (StrUtils.isEmpty(matchId))
            return new Result(CodeEnum.FAIL_100002.getCode(),CodeEnum.FAIL_100002.getMsg());
        return lotteryServerFeignClient.getESportsHead(matchId);
    }
}
